﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HelperPrototype.OtherForms
{
    public partial class XemPhieuTamUng : Form
    {
        private string _maPhieu;
        _DB.PhieuTamUng p;

        public XemPhieuTamUng(string maPhieuTamUng)
        {
            InitializeComponent();
            _maPhieu = maPhieuTamUng;
        }
        private void loadData()
        {
            _DB.DataClasses1DataContext dc = new _DB.DataClasses1DataContext();
            p = dc.PhieuTamUngs.Single(x => x.MaPhieu == _maPhieu);

            txtMaPhieu.Text = p.MaPhieu;
            txtNguoiTao.Text = p.NguoiTao.Ten;
            txtPhongBan.Text = (p.NguoiTao.PhongBan == null) ? "" : p.NguoiTao.PhongBan.TenPhongBan;
            txtNgayTao.Text = p.NgayTao.ToLongTimeString();
            txtNoiDung.Text = p.NoiDung;
            txtPhieuDeNghi.Text = p.QuyTrinhMuaHangs.Single().PhieuMuaHang.MaPhieu;
            txtSoTien.Text = p.SoTien.ToString();
        }
        private void XemPhieuTamUng_Load(object sender, EventArgs e)
        {
            loadData();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnView_Click(object sender, EventArgs e)
        {
            OtherForms.XemPhieuMuaHang f = new OtherForms.XemPhieuMuaHang(txtPhieuDeNghi.Text);
            f.Show();
        }

        private void btnQuyTrinh_Click(object sender, EventArgs e)
        {
            XemQuyTrinh f = new XemQuyTrinh(p.QuyTrinhMuaHangs.Single().ID);
            f.Show();
        }
    }
}
